<?php
/**
 * Form for adding and editing address
 */
class Page_Form_Page extends App_Form_FormAbstract
{
    /**
     * @see    Zend_Form::init()
     * @return void
     */
    public function init()
    {
        $this->setOptions(array(
            'method' => 'post',
            'elements' => array(
                'id' => array('hidden'),
                'title' => array('text', array(
                    'label'    => 'Titre',
                    'required' => true,
                    //TODO : ajouter un filtre 'filters'  => array('StringTrim')
                )),
                 'content' => array('textarea', array(
                    'label'    => 'content',
                    'required' => true,
                )),
                 'category_id' => array('text', array(
                    'label'    => 'Category',                 
                )),
                 'order' => array('text', array(
                    'label'    => 'Order',                   
                )),
                 'tags' => array('text', array(
                    'label'    => 'Tags',
                )),
                 'is_section' => array('checkbox', array(
                    'label'    => 'Is Setion',
                )),                
                'submit' => array('submit', array(
                    'label' => 'Enregistrer'
                ))
            )
        ));
    }
    
    public function getTablePreparedData(array $data)
    {
    	$result = $data;
    	
    	unset($result['submit']);
    	unset($result['id']);
    	
    	return $result;
    }
    
    public function populateByPageId($pageId)
    {
    	$page = new Page_Model_Page();
    	$data = $page->fetchById($pageId);
    	//print_r($data); exit;
    	$this->populate($data);
    }
}
